package com.icss.ah.productForShow.action;

import java.util.List;
import java.util.Map;

import net.sf.json.JSONObject;

import org.apache.commons.collections.map.HashedMap;
import org.apache.log4j.Logger;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.icss.ah.base.action.BaseAction;
import com.icss.ah.base.bean.EasyuiDataGridJson;
import com.icss.ah.login.bean.UserInfoBean;
@Controller
@Scope("prototype")
public class ProductForShowAction extends BaseAction {
	private final Logger errlog = Logger.getLogger("E");
	private final Logger infolog = Logger.getLogger("I");
	
	/**
	 * 前往店铺商品销售信息展示列表
	 */
	public String toProductForShowList(){
		return "toProductForShowList";
	}
	
	
	public void queryProductForShowList(){
		request=this.getRequest();
		String result="";
		try {
			String userCode=getUserCodeFromSession(); //获取当前登录者的登录名
			UserInfoBean userInfo=getUserInfo(userCode);
			String shopId=userInfo.getShopId();
			String productName=request.getParameter("productName")==null?"":request.getParameter("productName");
			Map map=new HashedMap();
			map.put("shopId",shopId);
			map.put("productName", productName);
			map.put("startNo", getStartIndexMysql());
			map.put("pageRows", getEndIndexMysql());
			List<Map> list=this.productForShowService.queryProductForShowList(map);
			long count=this.productForShowService.queryProductForShowCount(map);			
			dataGridJson=new EasyuiDataGridJson();
			dataGridJson.setRows(list);
			dataGridJson.setTotal(count);
			result=JSONObject.fromObject(dataGridJson).toString();
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("ProductForShowAction|queryProductForShowList",e);
		}finally{
			str2Resp(result);
		}
	}
}
